import { Controller } from "egg";
import validateInput from "../decorator/inputValidate";
import { testRules } from "../validatorRules/test";

export default class TestController extends Controller {
  public async index() {
    const { ctx } = this;
    ctx.body = await ctx.service.test.findList();
  }

  @validateInput(testRules, "createTestAlreadyExists")
  public async create() {
    const { ctx } = this;
    const { phoneNumber, password, nikeName, role } = ctx.request.body;
    ctx.helper.success({
      ctx,
      res: {
        phoneNumber,
        password,
        nikeName,
        role,
      },
    });
  }
}
